package com.lesama.test;

import com.lesama.domain.Student;

import java.util.ArrayList;

public class ArrayListTest4 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        list.add(new Student("ts", 24));
        list.add(new Student("rk", 25));
        list.add(new Student("elk", 25));
        list.add(new Student("on", 22));
        ArrayList<Student> newList = filter(list);
        System.out.println(newList);
    }

    private static ArrayList<Student> filter(ArrayList<Student> list) {
        ArrayList<Student> newList = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            if(stu.getAge() > 24) {
                newList.add(stu);
            }
        }
        return newList;
    }

}
